package com.five.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.five.dao.ClubPeopleDao;
import com.five.pojo.Club;
import com.five.pojo.ClubPeople;
import com.five.pojo.PageBean;
import com.five.service.ClubPeopleService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author lenovo
 */
@Service
public class ClubPeopleServiceImpl implements ClubPeopleService{
    @Autowired
    ClubPeopleDao clubPeopleDao;


    @Override
    public List<ClubPeople> findBycClub(String cClub) {
        List<ClubPeople> clubPeople = clubPeopleDao.findBycClub(cClub);
        return clubPeople;
    }

    //管理员移除社团成员
    @Override
    public void deleteById(Integer id) {
        clubPeopleDao.deleteById(id);
    }

    //管理员/团长添加社团成员
    @Override
    public void addStudent(ClubPeople clubPeople) {
        clubPeople.setCJoinClubTime(LocalDateTime.now());
        clubPeopleDao.addStudent(clubPeople);
    }

    //分页条件查询所有
    @Override
    public PageBean page(Integer pageNumber, Integer pageSize, String cClub, String sName) {
        //设置分页参数
        PageHelper.startPage(pageNumber , pageSize);
        //执行查询
        List<ClubPeople> clubPeopleList = clubPeopleDao.list(cClub , sName);
        Page<ClubPeople> p =(Page<ClubPeople>) clubPeopleList;
        //封装PageBean对象
        PageBean pageBean = new PageBean(p.getTotal() , p.getResult());
        return pageBean;
    }



}
